// pages/spend/spend.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    keti: 125.10,
    spendNum: null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  spendAll:function(){
    var that = this;
    that.setData({
      spendNum: that.data.keti
    })
  },

  soMoney:function(e){
    if (e.detail.value){
      this.setData({
        spendNum: e.detail.value
      })
    }else{
      wx.showToast({
        icon: 'none',
        title: '请输入正确的金额',
      })
    }
  },

  spendNow:function(){
    var that = this;
    var rich = Number(that.data.spendNum).toFixed(2);
    var spendmoney = parseFloat(rich);
    if (spendmoney == null || spendmoney == 0){
      wx.showToast({
        icon: 'none',
        title: '请输入正确的金额',
      })
    } else if (that.data.spendNum > that.data.keti){
      wx.showToast({
        icon: 'none',
        title: '超出可提金额',
      })
    }else{
      wx.showToast({
        icon: 'none',
        title: '测试提现金额' + spendmoney,
      })
      setTimeout(function(){
        wx.navigateBack({})
      },1000)
    }
  }
})